import React, { PropTypes, Component } from 'react';
import {myAjax, ROOTURL_TABLE, ROOTPATH} from './../publicAPI/publicAPI';
import fetch from 'isomorphic-fetch';




export default React.createClass({
	getInitialState: function() {

	    return {
	    	/*shopName: '',
	    	assistantName: [],
	    	shopForTypes: [],
	    	payment: [],

	    	ifEditForSerTypes: false,*/
		};
	},

	/*componentWillMount: function() {
		let _this = this;
		//获取所有店铺名以及每个的所属理发师、洗头员
		fetch(ROOTURL_TABLE + 'cafune/servant/serdaystdata.api', { 
			method: 'GET',
			headers: { 
			    "Content-type": "application/x-www-form-urlencoded; charset=UTF-8" 
			}, 
			//body: analysisJson(param) 
		})
		.then((response) => {
			console.log(response);
			if (response.ok) {
				console.log('ok');
				response.json().then(function(data) {
					console.log(data);
					//处理数据
					
				}.bind(_this));
			} else {
				console.log("Looks like the response wasn't perfect, got status", response.status);
			}

		})
		.catch(function (error) {
			alert("获取服务器内容失败");
			console.log('Request failed', error);
		});
	},

	handleSubmit: function() {
		//判断数据是否为空，是否格式正确
		if(this.state.shopName && this.state.assistantName && this.state.service && this.state.price && this.state.payMethod && this.state.servantName) {

		} else {
			alert('项目不能为空或格式错误!');
		}
		//发送数据至服务器
		myAjax(url, 'POST', param, function(data) {
			if(data.token) {
				location.href = '/'					
			}
		}, function(error) {
			alert('录入失败');
		});
		
	},
	handleKeyPress: function(e) {
	    if(e.which == 13) {
	        this.handleSubmit();
	    }
	},
	editForSerTypes: function() {
		this.setState({
			ifEditForSerTypes: !this.state.ifEditForSerTypes,
		});
		this.state.ifEditForSerTypes? this.refs.editButton1.innerHTML = '保存' : this.refs.editButton1.innerHTML = '编辑';
	},
	deleteTypesInput: function(index) {
		if(this.state.dataForTypes.length <= 1) { return }
		let processData = this.state.dataForTypes.splice(index, 1);
		this.setState({
			dataForTypes: processData,
		});
	},*/

	render: function() {
		//console.log(this.state.tData);
		return (
			<div>
		    	<div>
		    		<p>门店：<input type="text" /></p>
		    		<p>服务：<input type="text" /></p>
		    		<p>理发师提成：&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		    			指定<input style={{width: '100px'}} type="text" />
		    			非指定<input style={{width: '100px'}} type="text" />
		    		</p>
		    		<p>助理提成：<input style={{width: '100px'}} type="text" /></p>
		    	</div>
		    	
		    	<div>
					<button>保存</button>
					<button>清空</button>
				</div>
    		</div>
		);
		
	}
});
    
